home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / program / swmp141.zip / C_SDK.ZIP / MODPLAY.INC < prev   
Text File  |  1995-12-12  |  3KB  |  192 lines

  1. /* ╓──────────────────────────────────────────────────╖ */
  2. /* ║ SOUND WIZARDS MODULE PLAYER V1.41 BY LORD EXCESS ║ */
  3. /* ╙──────────────────────────────────────────────────╜ */
  4.  
  5. #include <stdlib.h>
  6.  
  7. #define Detection         0
  8. #define SoundBlaster      1
  9. #define SoundBlaster_Pro  2
  10. #define Gravis_UltraSound 3
  11.  
  12. unsigned int Soundcard, Channels;
  13. void far *Mod_Driver;
  14. unsigned char Peak[8];
  15.  
  16. extern void far Detect_Hardware(void);
  17. extern void far Driver_SB(void);
  18. extern void far Driver_SBP(void);
  19. extern void far Driver_GUS(void);
  20.  
  21. void Mod_Close(void)
  22. {
  23.  asm {
  24.   mov     bx,1
  25.   call    DWORD PTR [Mod_Driver]
  26.  }
  27. }
  28.  
  29. void Mod_Init(unsigned int Driver, unsigned int Port, unsigned char IRQ, unsigned char DMA)
  30. {
  31.  asm {
  32.   mov     ax,[Driver]
  33.   or      ax,ax
  34.   jz      l_1
  35.   cmp     ax,Gravis_UltraSound
  36.   ja      l_Error
  37.   mov     cl,BYTE PTR [IRQ]
  38.   mov     ch,BYTE PTR [DMA]
  39.   mov     dx,[Port]
  40.   jmp     l_2
  41.  }
  42. l_1:
  43.   Detect_Hardware();
  44.  asm {
  45.   or      ax,ax
  46.   jz      l_Error
  47.   cmp     ax,Gravis_UltraSound
  48.   ja      l_Error
  49.  }
  50. l_2:
  51.  asm {
  52.   mov     [Soundcard],ax
  53.   mov     WORD PTR [Mod_Driver],0
  54.   cmp     ax,SoundBlaster
  55.   jnz     l_3
  56.   mov     WORD PTR [Mod_Driver+2],SEG Driver_SB
  57.   jmp     l_Test
  58.  }
  59. l_3:
  60.  asm {
  61.   cmp     ax,SoundBlaster_Pro
  62.   jnz     l_4
  63.   mov     WORD PTR [Mod_Driver+2],SEG Driver_SBP
  64.   jmp     l_Test
  65.  }
  66. l_4:
  67.  asm {
  68.   mov     WORD PTR [Mod_Driver+2],SEG Driver_GUS
  69.  }
  70. l_Test:
  71.  asm {
  72.   xor     bx,bx
  73.   call    DWORD PTR [Mod_Driver]
  74.   or      ax,ax
  75.   jz      l_Error
  76.  }
  77.  if (atexit(Mod_Close)) {
  78.   Mod_Close();
  79. l_Error:
  80.   asm {
  81.    mov     [Soundcard],0
  82.   }
  83.  }
  84. }
  85.  
  86. void Mod_Load(char far *File_Name)
  87. {
  88.  if (Soundcard) asm {
  89.   push    ds
  90.   push    es
  91.   mov     ax,ds
  92.   mov     es,ax
  93.   mov     bx,2
  94.   lds     dx,DWORD PTR [File_Name]
  95.   call    DWORD PTR es:[Mod_Driver]
  96.   pop     es
  97.   pop     ds
  98.   mov     [Channels],ax
  99.  }
  100.  else Channels=0;
  101. }
  102.  
  103. void Mod_Play(unsigned int Looping)
  104. {
  105.  if (Soundcard) asm {
  106.   mov     bx,3
  107.   mov     ax,[Looping]
  108.   call    DWORD PTR [Mod_Driver]
  109.  }
  110. }
  111.  
  112. void Mod_Stop(void)
  113. {
  114.  if (Soundcard) asm {
  115.   mov     bx,4
  116.   call    DWORD PTR [Mod_Driver]
  117.  }
  118. }
  119.  
  120. void Mod_Volume(unsigned char Volume)
  121. {
  122.  if (Soundcard) asm {
  123.   mov     bx,5
  124.   mov     al,[Volume]
  125.   call    DWORD PTR [Mod_Driver]
  126.  }
  127. }
  128.  
  129. unsigned int Mod_Status(void)
  130. {
  131.  if (Soundcard) {
  132.   asm {
  133.    mov     bx,6
  134.    call    DWORD PTR [Mod_Driver]
  135.   }
  136.   return(_AX);
  137.  }
  138.  else return(0);
  139. }
  140.  
  141. unsigned int Mod_Position(void)
  142. {
  143.  if (Soundcard) {
  144.   asm {
  145.    mov     bx,7
  146.    xor     al,al
  147.    call    DWORD PTR [Mod_Driver]
  148.   }
  149.   return(_AX);
  150.  }
  151.  else return(0);
  152. }
  153.  
  154. void Mod_Rewind(void)
  155. {
  156.  if (Soundcard) asm {
  157.   mov     bx,7
  158.   mov     al,-1
  159.   call    DWORD PTR [Mod_Driver]
  160.  }
  161. }
  162.  
  163. void Mod_Forward(void)
  164. {
  165.  if (Soundcard) asm {
  166.   mov     bx,7
  167.   mov     al,1
  168.   call    DWORD PTR [Mod_Driver]
  169.  }
  170. }
  171.  
  172. void Mod_Peak(void)
  173. {
  174.  asm {
  175.   push    es
  176.   mov     ax,ds
  177.   mov     es,ax
  178.   mov     di,OFFSET Peak
  179.  }
  180.  if (Soundcard) asm {
  181.   mov     bx,8
  182.   call    DWORD PTR [Mod_Driver]
  183.  }
  184.  else asm {
  185.   cld
  186.   mov     cx,4
  187.   xor     ax,ax
  188.   rep     stosw
  189.  }
  190.   asm pop    es;
  191. }
  192.